package com.Jeu;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Splash extends ScreenActivity implements OnClickListener {

	// private boolean continueMusic = false;
	public boolean pausing = false;
	public static boolean iscontinue = true;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (iscontinue) {
			setContentView(R.layout.splash);
			Audio.setVolume(R.raw.musicbackground, 0);
			Button bt_y = (Button) findViewById(R.id.bt_yes);
			bt_y.setOnClickListener(this);
			Button bt_n = (Button) findViewById(R.id.bt_no);
			bt_n.setOnClickListener(this);
			iscontinue = false;
		} else
			nextScreen();
	}

	public void nextScreen() {
		continueMusic = true;
		Intent nextIntent = new Intent(this, Menu.class);
		this.startActivity(nextIntent);
		finish();
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		return true;
	}

	@Override
	protected void onResume() {
		continueMusic = false;
		pausing = false;
		super.onResume();
	}

	@Override
	public void onPause() {
		if (!continueMusic) {
			Audio.pause(R.raw.musicbackground);
		}
		pausing = true;
		super.onPause();
	}

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub

		switch (arg0.getId()) {
		case R.id.bt_yes:
			Log.w("btYes:::::", "1111111");
			Audio.setVolume(R.raw.musicbackground, 0);
			Audio.play(R.raw.musicbackground, true);
			continueMusic = true;
			nextScreen();
			break;
		case R.id.bt_no:
			Log.w("btNo:::::", "0000000000");
			Audio.setVolume(R.raw.musicbackground, 0.5f);
			Audio.play(R.raw.musicbackground, true);
			continueMusic = true;
			nextScreen();
			break;
		}
	}
}
